import { createSlice } from '@reduxjs/toolkit';

const initialState = {
  TrainDryingData: {}, // 存储第二次预测返回的后端数据
  predictedDryingTime: null, // 来料水分预测模型训练耗时
  predictedDehydrationTime: null, // 烘丝机参数模型训练耗时
};

const TrainModelSlice = createSlice({
  name: 'TrainModel',
  initialState,
  reducers: {
    // 更新第二次预测数据
    updateTrainData(state, action) {
      state.TrainDryingData = action.payload;
    },
    // 更新来料水分预测值和脱水量
    updateTrainTime(state, action) {
      const { predictedDryingTime, predictedDehydrationTime } = action.payload;
      state.predictedDryingTime = predictedDryingTime;
      state.predictedDehydrationTime = predictedDehydrationTime;
    },
    // 清空所有数据
    clearTrainData(state) {
      state.TrainDryingData = {};
       predictedDryingTime = null;
      state.predictedDehydrationTime = null;
      },
  },
})
export const { updateTrainData, updateTrainTime, clearTrainData } = TrainModelSlice.actions;
export default TrainModelSlice.reducer;